<?php

  $key_num = trim($key,'c');
 
  echo $form[$key][$id]->renderError(); 

  $id_actual = $form[$key]['idCaracteristica']->getValue();
  
  try {
    $id_anterior = $form['c'.($key_num-1)]['idCaracteristica']->getValue();
  } catch (Exception $e){
    $id_anterior = -1;
  }
  
  try {
    $id_posterior = $form['c'.($key_num+1)]['idCaracteristica']->getValue();
  } catch (Exception $e){
    $id_posterior = -1;
  }
  
  if ($id_posterior == $id_actual) {
    $no_display_add = 'style="display: none;"';
  }else{
    $no_display_add = '';
  }
  
  if (($id_anterior != $id_actual) && ($id_posterior != $id_actual)) {
    $no_display_delete = 'style="display: none;"';
  }else{
    $no_display_delete = '';
  }
  
  
  if ($id_actual == $id_anterior) {
    $no_display_label = array( 'style' => 'display: none;');
    $change_margin = array( 'class' => 'con_margen');
  }else{
    $no_display_label = array();
    $change_margin = array();
  }
  
  echo $form[$key][$id]->renderLabel(null,$no_display_label);
  
  echo $form[$key][$id]->render($change_margin);
  echo $form[$key]['id']->render();

?>

  <ul class="control" class="ui-widget ui-helper-clearfix">
    <li class="ui-state-default ui-corner-all add" <?php echo $no_display_add; ?> title="Agregar"><span onclick="addRepetible(this);" value="<?php echo $id_caracteristica ?>" class="ui-icon ui-icon-plus add_repetible"></span></li>
    <li class="ui-state-default ui-corner-all remove" <?php echo $no_display_delete; ?> title="Eliminar"><span onclick="eliminarRepetible(this);" class="ui-icon ui-icon-minus remove_repetible"></span></li>
  </ul>